# _*_ coding: utf-8 _*_
"""
Time:     2024/8/30
Author:   2051261
File:     decorate_tool.py
"""
import functools
import logging

logger = logging.getLogger(__name__)


async def db_exception(func):
    @functools.wraps(func)
    def wrapper(*args, **kwargs):
        try:
            return func(*args, **kwargs)
        except Exception as e:
            logger.error(f"Database operation failed in {func.__name__}: {e}")
            raise
    return wrapper


async def dict_keys_to_lowercase(d: dict) -> dict:
    return {k.lower(): v for k, v in d.items()}


async def list_elements_to_lowercase(lst: list[str]) -> list:
    return [e.lower() for e in lst]
